package com.toutou.base.bindhelper

import android.widget.LinearLayout
import androidx.databinding.BindingAdapter

class LinearLayoutBDAdapter {
    companion object {
        @JvmStatic
        @BindingAdapter("isVertical")
        fun setOrientationVertical(view: LinearLayout, isVertical: Boolean) {
            view.orientation = if (isVertical) LinearLayout.VERTICAL else LinearLayout.HORIZONTAL
        }

//        设置内部排版策略
        @JvmStatic
        @BindingAdapter("layoutGravity")
        fun setLayoutGravity(view: LinearLayout, gravity: Int) {
//            设置layout_gravity
            val layoutParams = view.layoutParams as LinearLayout.LayoutParams
            layoutParams.gravity = gravity
            view.layoutParams = layoutParams
        }

    }
}